﻿using System;
using Glue;
using Xunit;

namespace GluePerformanceTesting
{
    public class SimpleMapping
    {
        private readonly PerformanceMeasure measurer;

        private class GuiPerson { public String Name { get; set; } }
        private class DomainPerson { public String Name { get; set; } }

        public SimpleMapping()
        {
            measurer = PerformanceMeasure.GetInstance();
        }

        [Fact]
        public void Run_everything()
        {
            var domainPerson = new DomainPerson {Name = "Tore"};
            measurer.Run("Simple mapping, end to end", () =>
            {
                var mapping = new Mapping<DomainPerson, GuiPerson>();
                mapping.AutoRelateEqualNames();
                mapping.Map(domainPerson, new GuiPerson());
            });
        }

        [Fact]
        public void Run_mapping_only()
        {
            var mapping = new Mapping<DomainPerson, GuiPerson>();
            mapping.AutoRelateEqualNames();
            var domainPerson = new DomainPerson { Name = "Tore" };
            measurer.Run("Simple mapping, mapping only", () => mapping.Map(domainPerson, new GuiPerson()));
        }
    }
}
